import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'page',
    meta: {
      title: '首页'
    },
    component: () => import('../views/page.vue'),
    children: [
      {
        path: 'dashboard/analysis',
        name: 'dashboard/analysis',
        meta: {
          title: '首页'
        },
        component: () => import('../views/index.vue')
      },
      {
        path: 'erp/stock/purIn',
        name: 'erp/stock/purIn',
        meta: {
          title: '采购入库'
        },
        component: () => import('../views/stock/purln.vue')
      },
      {
        path: 'erp/stock/rubricPurIn',
        name: 'erp/stock/rubricPurIn',
        meta: {
          title: '采购退货出库'
        },
        component: () => import('../views/stock/rubricPurIn.vue')
      },
      {
        path: 'erp/stock/checkIn',
        name: 'erp/stock/checkIn',
        meta: {
          title: '盘盈入库'
        },
        component: () => import('../views/stock/checkIn.vue')
      },
      {
        path: 'erp/stock/swellIn',
        name: 'erp/stock/swellIn',
        meta: {
          title: '涨库入库'
        },
        component: () => import('../views/stock/swellIn.vue')
      },
      {
        path: 'erp/stock/otherIn',
        name: 'erp/stock/otherIn',
        meta: {
          title: '其他入库'
        },
        component: () => import('../views/stock/otherIn.vue')
      },
      {
        path: 'erp/stock/SalOut',
        name: 'erp/stock/SalOut',
        meta: {
          title: '销售出库'
        },
        component: () => import('../views/stock/SalOut.vue')
      },
      {
        path: 'erp/stock/rubricSalOut',
        name: 'erp/stock/rubricSalOut',
        meta: {
          title: '销售退货入库'
        },
        component: () => import('../views/stock/rubricSalOut.vue')
      },
      {
        path: 'erp/stock/checkOut',
        name: 'erp/stock/checkOut',
        meta: {
          title: '亏盘出库'
        },
        component: () => import('../views/stock/checkOut.vue')
      },
      {
        path: 'erp/stock/otherOut',
        name: 'erp/stock/otherOut',
        meta: {
          title: '其他出库'
        },
        component: () => import('../views/stock/otherOut.vue')
      },
      {
        path: 'erp/stock/Move',
        name: 'erp/stock/Move',
        meta: {
          title: '库存调拨'
        },
        component: () => import('../views/stock/Move.vue')
      },
      {
        path: 'erp/stock/changeCost',
        name: 'erp/stock/changeCost',
        meta: {
          title: '成本调整'
        },
        component: () => import('../views/stock/changeCost.vue')
      },
      {
        path: 'erp/stock/Check',
        name: 'erp/stock/Check',
        meta: {
          title: '库存盘点'
        },
        component: () => import('../views/stock/Check.vue')
      },
      {
        path: 'erp/stock/inventory',
        name: 'erp/stock/inventory',
        meta: {
          title: '实时库存'
        },
        component: () => import('../views/stock/inventory.vue')
      },
      {
        path: 'erp/finance/salPreeceipt',
        name: 'erp/finance/salPreeceipt',
        meta: {
          title: '销售预收'
        },
        component: () => import('../views/finance/salPreeceipt.vue')
      },
      {
        path: 'erp/finance/salReceipt',
        name: 'erp/finance/salReceipt',
        meta: {
          title: '销售收款'
        },
        component: () => import('../views/finance/salReceipt.vue')
      },
      {
        path: 'erp/finance/otherReceipt',
        name: 'erp/finance/otherReceipt',
        meta: {
          title: '其他收款'
        },
        component: () => import('../views/finance/otherReceipt.vue')
      },
      {
        path: 'erp/finance/purPrepayment',
        name: 'erp/finance/purPrepayment',
        meta: {
          title: '采购预付'
        },
        component: () => import('../views/finance/purPrepayment.vue')
      },
      {
        path: 'erp/finance/purPayment',
        name: 'erp/finance/purPayment',
        meta: {
          title: '采购付款'
        },
        component: () => import('../views/finance/purPayment.vue')
      },
      {
        path: 'erp/finance/otherPayment',
        name: 'erp/finance/otherPayment',
        meta: {
          title: '其他付款'
        },
        component: () => import('../views/finance/otherPayment.vue')
      },
      {
        path: 'erp/finance/salReceivable',
        name: 'erp/finance/salReceivable',
        meta: {
          title: '销售应收'
        },
        component: () => import('../views/finance/salReceivable.vue')
      },
      {
        path: 'erp/finance/otherReceivable',
        name: 'erp/finance/otherReceivable',
        meta: {
          title: '其他应收'
        },
        component: () => import('../views/finance/otherReceivable.vue')
      },
      {
        path: 'erp/finance/receivableCheck',
        name: 'erp/finance/receivableCheck',
        meta: {
          title: '收款核应收'
        },
        component: () => import('../views/finance/receivableCheck.vue')
      },
      {
        path: 'erp/finance/purPayable',
        name: 'erp/finance/purPayable',
        meta: {
          title: '采购应付'
        },
        component: () => import('../views/finance/purPayable.vue')
      },
      {
        path: 'erp/finance/otherPayabl',
        name: 'erp/finance/otherPayabl',
        meta: {
          title: '其他应付'
        },
        component: () => import('../views/finance/otherPayabl.vue')
      },
      {
        path: 'erp/finance/payableCheck',
        name: 'erp/finance/payableCheck',
        meta: {
          title: '付款核应付'
        },
        component: () => import('../views/finance/payableCheck.vue')
      },
      {
        path: 'erp/finance/salInvoice',
        name: 'erp/finance/salInvoice',
        meta: {
          title: '销售发票'
        },
        component: () => import('../views/finance/salInvoice.vue')
      },
      {
        path: 'erp/finance/rubricSalInvoice',
        name: 'erp/finance/rubricSalInvoice',
        meta: {
          title: '销售发票（红字）'
        },
        component: () => import('../views/finance/rubricSalInvoice.vue')
      },
      {
        path: 'erp/finance/purInvoice',
        name: 'erp/finance/purInvoice',
        meta: {
          title: '采购发票'
        },
        component: () => import('../views/finance/purInvoice.vue')
      },
      {
        path: 'erp/finance/rubricPurInvoice',
        name: 'erp/finance/rubricPurInvoice',
        meta: {
          title: '采购发票（红字）'
        },
        component: () => import('../views/finance/rubricPurInvoice.vue')
      },
      {
        path: 'finer/erp/bas/monthCarryForward',
        name: 'finer/erp/bas/monthCarryForward',
        meta: {
          title: '月末转结'
        },
        component: () => import('../views/finance/monthCarryForward.vue')
      },
      {
        path: 'online/cgreport/1259783869488844801',
        name: 'online/cgreport/1259783869488844801',
        meta: {
          title: '销售出库'
        },
        component: () => import('../views/finance/online/cgreport.vue')
      },
      {
        path: 'erp/bas/customer',
        name: 'erp/bas/customer',
        meta: {
          title: '客户'
        },
        component: () => import('../views/bas/customer.vue')
      },
      {
        path: 'erp/bas/supplier',
        name: 'erp/bas/supplier',
        meta: {
          title: '供应商'
        },
        component: () => import('../views/bas/supplier.vue')
      },
      {
        path: 'erp/bas/warehouse',
        name: 'erp/bas/warehouse',
        meta: {
          title: '仓库'
        },
        component: () => import('../views/bas/warehouse.vue')
      },
      {
        path: 'erp/bas/materialCategory',
        name: 'erp/bas/materialCategory',
        meta: {
          title: '物料分类'
        },
        component: () => import('../views/bas/materialCategory.vue')
      },
      {
        path: 'erp/bas/material',
        name: 'erp/bas/material',
        meta: {
          title: '物料'
        },
        component: () => import('../views/bas/material.vue')
      },
      {
        path: 'erp/bas/measureUnit',
        name: 'erp/bas/measureUnit',
        meta: {
          title: '计量单位'
        },
        component: () => import('../views/bas/measureUnit.vue')
      },
      {
        path: 'erp/bas/currency',
        name: 'erp/bas/currency',
        meta: {
          title: '币种'
        },
        component: () => import('../views/bas/currency.vue')
      },
      {
        path: 'erp/bas/bankAccount',
        name: 'erp/bas/bankAccount',
        meta: {
          title: '银行账户'
        },
        component: () => import('../views/bas/bankAccount.vue')
      },
      {
        path: 'isystem/user',
        name: 'isystem/user',
        meta: {
          title: '用户管理'
        },
        component: () => import('../views/isystem/user.vue')
      },
      {
        path: 'isystem/role',
        name: 'isystem/role',
        meta: {
          title: '角色管理'
        },
        component: () => import('../views/isystem/role.vue')
      },
      {
        path: 'isystem/permission',
        name: 'isystem/permission',
        meta: {
          title: '菜单管理'
        },
        component: () => import('../views/isystem/permission.vue')
      },
      {
        path: 'isystem/depart',
        name: 'isystem/depart',
        meta: {
          title: '部门管理'
        },
        component: () => import('../views/isystem/depart.vue')
      },
      {
        path: 'isystem/departUserList',
        name: 'isystem/departUserList',
        meta: {
          title: '我的部门'
        },
        component: () => import('../views/isystem/departUserList.vue')
      },
      {
        path: 'isystem/dict',
        name: 'isystem/dict',
        meta: {
          title: '数据字典'
        },
        component: () => import('../views/isystem/dict.vue')
      },
      {
        path: 'isystem/checkRule',
        name: 'isystem/checkRule',
        meta: {
          title: '编码效验规则'
        },
        component: () => import('../views/isystem/checkRule.vue')
      },
      {
        path: 'isystem/position',
        name: 'isystem/position',
        meta: {
          title: '职务管理'
        },
        component: () => import('../views/isystem/position.vue')
      },
      {
        path: 'isystem/roleUserList',
        name: 'isystem/roleUserList',
        meta: {
          title: '角色遍历'
        },
        component: () => import('../views/isystem/roleUserList.vue')
      },
      {
        path: 'isystem/dataSource',
        name: 'isystem/dataSource',
        meta: {
          title: '多数据管理'
        },
        component: () => import('../views/isystem/dataSource.vue')
      }, {
        path: 'isystem/addressList',
        name: 'isystem/addressList',
        meta: {
          title: '通讯录'
        },
        component: () => import('../views/isystem/addressList.vue')
      },
      {
        path: 'isys/category',
        name: 'isys/category',
        meta: {
          title: '分类字典'
        },
        component: () => import('../views/isystem/category.vue')
      },

      {
        path: 'isystem/annountCement',
        name: 'isystem/annountCement',
        meta: {
          title: '系统通知'
        },
        component: () => import('../views/isystem/annountCement.vue')
      },
      {
        path: 'modules/message/sysMessageList',
        name: 'modules/message/sysMessageList',
        meta: {
          title: '消息管理'
        },
        component: () => import('../views/message/sysMessageList.vue')
      },
      {
        path: 'modules/message/sysMessageTemplateList',
        name: 'modules/message/sysMessageTemplateList',
        meta: {
          title: '模板管理'
        },
        component: () => import('../views/message/sysMessageTemplateList.vue')
      },
      {
        path: 'online/cgform',
        name: 'online/cgform',
        meta: {
          title: 'Online表单开发'
        },
        component: () => import('../views/online/cgform.vue')
      },
      {
        path: 'online/cgreport',
        name: 'online/cgreport',
        meta: {
          title: '报表配置'
        },
        component: () => import('../views/online/cgreport.vue')
      },
      {
        path: 'isystem/fillRule',
        name: 'isystem/fillRule',
        meta: {
          title: '系统编码规则'
        },
        component: () => import('../views/online/fillRule.vue')
      },
    ]
  },
  {
    path: '/login',
    name: 'login',
    meta: {
      title: '登录'
    },
    component: () => import('../views/login.vue')
  }
]


const router = new VueRouter({
  routes
})
// 导航守卫
// router.beforeEach((to, from, next) => {
//   const token = sessionStorage.getItem('token')
//   if (token) {
//     if (to.path != '/login') {
//       next()
//     } else {
//       next('/dashboard/analysis')
//     }
//   } else {
//     if (to.path != '/login') {
//       next('/login')
//     } else {
//       next()
//     }
//   }
// })
export default router
